<div class="mainpad">
	<form action="" method="post" id="subfrom">
		<ul class="subwrite">
			<li><input type="text" name="title" class="title" id="title"><span class="notice tt">文章标题，简洁不超过30个汉字.</span></li>
			<li><div contenteditable=true id="descp"></div><span class="notice area">文章中心描述，本文所要介绍的主要类容不超过200个汉字.</span><div class="textarea"><textarea name="descp"></textarea></div></li>
			<li><div contenteditable=true id="content"></div><span class="notice area">文章内容，文章中如需插入图片，代码请换行插入，提交后系统会自动编辑。</span><div class="textarea"><textarea name="content"></textarea></div></li>
			<li><input type="submit" value="提交" class="butt"/></li>
		</ul>
	</form>
</div>
<script>
	$('.notice').click(function(){$(this).siblings('input,#descp,#content').focus();});
	$('#title,#descp,#content').bind({
	  blur: function() {
		$(this).css({'borderWidth':1});putTextarea();
		if(this.id == "title")
		{
			var v = this.value;
		}else{
			var v = $(this).text();
		}
		!v.replace(/(^\s*)|(\s*$)/g, "") ? $(this).siblings('.notice').show():'';
	  },
	  focus: function() {
		$(this).css({'borderWidth':2});putTextarea();$(this).siblings('.notice').hide();
	  }
	})
	
	$('#subfrom').submit(function(){
		var title = $('#title').val();
		var descp = $('#descp').html();
		var content = $('#content').html();
		if(!title || !descp || !content)return false;		
	})

	function putTextarea()
	{
		var d = $('#descp').html();
		var c = $('#content').html();
		$('textarea[name=descp]').val(divEdite(d));
		$('textarea[name=content]').val(divEdite(c));
	}

	function divEdite(html)
	{
		html = html.replace(/&nbsp;/gi,"").replace(/<br>/gi,"\n").replace(/<div>/gi, "\n").replace(/<\/div>/gi,"\n").replace(/<P>/gi,"").replace(/<\/P>/gi,"");		
		return html;
	}
</script>